//
//  TCM_HomeEntryTableViewCell.swift
//  TCM_TradingProject
//
//  Created by 吕春海 on 2018/8/21.
//  Copyright © 2018年 lvchunhai. All rights reserved.
//

import UIKit

class TCM_HomeEntryTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDataSource {

    var entryNameArr = [String]()
    var entryImageArr = [String]()
    
    @IBOutlet weak var entryCollectionView: UICollectionView!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        let layout = UICollectionViewFlowLayout.init()
        layout.itemSize = CGSize.init(width: (TCM_ScreenWidth - 4)/5, height: 110)
        layout.minimumInteritemSpacing = 0
        layout.sectionInset = UIEdgeInsets.init(top: 0, left: 2, bottom: 0, right: 2)
        
        self.entryCollectionView.collectionViewLayout = layout
        
        self.entryCollectionView.delegate = self
        self.entryCollectionView.dataSource = self
        
        self.entryCollectionView!.register(UINib.init(nibName: "TCM_HomeQuickEntryCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "entryCell")

    }

    func numberOfSections(in collectionView: UICollectionView) -> Int {
        return 1
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return entryNameArr.count
    }
    //cellForItemAt indexPath
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell = entryCollectionView.dequeueReusableCell(withReuseIdentifier: "entryCell", for: indexPath) as! TCM_HomeQuickEntryCollectionViewCell
        cell.entryLabel.text = entryNameArr[indexPath.row]
        cell.entryImageView.image = UIImage(named: entryImageArr[indexPath.row])
        return cell
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
